package com.trace.controller;

import com.alibaba.fastjson.JSONObject;
import com.request.invoke.SendRequestPostProcess;
import com.rlyy.basic.config.ApplicationContextUtil;
import com.rlyy.common.param.Request;
import com.rlyy.common.response.Result;
//import com.rlyy.grpc.client.GrpcClientServer;
import com.trace.User;
import com.trace.call.UserClientServer;
import com.trace.service.AService;
import io.grpc.Channel;
import io.grpc.ClientInterceptor;
import io.grpc.ManagedChannelBuilder;
import net.devh.boot.grpc.client.channelfactory.AbstractChannelFactory;
import net.devh.boot.grpc.client.channelfactory.GrpcChannelConfigurer;
import net.devh.boot.grpc.client.channelfactory.InProcessChannelFactory;
import net.devh.boot.grpc.client.config.GrpcChannelProperties;
import net.devh.boot.grpc.client.config.GrpcChannelsProperties;
import net.devh.boot.grpc.client.inject.GrpcClient;
import net.devh.boot.grpc.client.interceptor.GlobalClientInterceptorRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.lang.reflect.Field;
import java.net.URI;
import java.util.*;

/**
 * @author yuanqinglong
 * @since 2021/10/13 9:32
 */
@RestController
public class AController {


    static final Logger logger = LoggerFactory.getLogger(AController.class);

    @Autowired
    UserClientServer userClientServer;
    @Autowired
    ApplicationContextUtil applicationContextUtil;

    @Autowired
    GlobalClientInterceptorRegistry globalClientInterceptorRegistry;

    @Autowired
    List<GrpcChannelConfigurer> channelConfigurers;


    @RequestMapping("trace1")
    public Result test(Request request) throws NoSuchFieldException, IllegalAccessException {
        Object result = userClientServer.userAdd("1");
        Result result2 = userClientServer.userQuery("2", new User("zzz", "2"));
        Result result3 = userClientServer.userQuery2("1", new User("xxx", "3"));
        return result2;
    }

    public Channel createChannel(String name, List<ClientInterceptor> interceptors) {
        return null;
    }

    protected ManagedChannelBuilder newChannelBuilder(String name) {
        return null;
    }

    private static Object object1 = new Object();
    private static Object object2 = new Object();
    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 1000000000; i++) {
            String.valueOf(i).intern();
        }
    }
}
